package global

import (
	"github.com/gin-gonic/gin"
	"github.com/mark3labs/mcp-go/server"
	"github.com/spf13/viper"
	"go.uber.org/zap"
	"gorm.io/gorm"
	"mcp-demo/internal/config/cmodel"
	"sync"
)

var (
	ENV      string   // 当前环境
	DB       *gorm.DB // 数据库连接
	DB_DORIS *gorm.DB // Doris数据库连接
	//G_DBList        map[string]*gorm.DB
	CONFIG     cmodel.Server
	L          *zap.Logger
	VP         *viper.Viper
	ROUTERS    gin.RoutesInfo
	MCP_SERVER *server.MCPServer
	lock       sync.RWMutex
)

// GetGlobalDBByDBName 通过名称获取db
//func GetGlobalDBByDBName(dbName string) *gorm.DB {
//	lock.RLock()
//	defer lock.RUnlock()
//	return G_DBList[dbName]
//}

// GetGlobalDBByDBNameNotNil 通过名称获取db 不能为空
//func GetGlobalDBByDBNameNotNil(dbName string) *gorm.DB {
//	lock.RLock()
//	defer lock.RUnlock()
//	db, ok := G_DBList[dbName]
//	if !ok || db == nil {
//		panic("db未初始化")
//	}
//	return db
//}
